#include <cstdlib>
#include <iostream>
#include <string>

// PAT A 1077 Kuchiguse (口癖)

int main() {
    std::string line;
    std::getline(std::cin, line);
    int n = atoi(line.c_str());
    std::string suffix;
    for (int i = 0; i < n; i++) {
        // Read line
        std::getline(std::cin, line);
        if (line.length() == 0) {
            suffix.clear();
            break;
        }
        if (i == 0) {
            suffix = line;
            continue;
        }

        // Compare string backward
        int common = 0;
        int lineLen = line.length();
        int suffixLen = suffix.length();
        for (int si = suffixLen - 1; si >= 0; si--) {
            int li = lineLen - suffixLen + si;
            if (li < 0) break;
            if (line[li] == suffix[si])
                common++;
            else
                break;
        }
        if (common == 0) {
            suffix.clear();
            break;
        }
        suffix = suffix.substr(suffix.length() - common);
    }

    // Print result
    if (suffix.length() == 0)
        printf("nai\n");
    else
        printf("%s\n", suffix.c_str());
    
}